package com.flybear.aqi.client;

import org.elasticsearch.common.bytes.BytesReference;


import java.io.IOException;
import java.nio.charset.Charset;
import java.util.Map;

/**
 * Interface for an event serializer which serializes the headers and body of an
 * event to write them to ElasticSearch. This is configurable, so any config
 * params required should be taken through this.
 */
public interface ElasticSearchEventSerializer  {

  public static final Charset charset = Charset.defaultCharset();

  /**
   * Return an {@link BytesStream} made up of the serialized flume event
   * @param event
   *          The flume event to serialize
   * @return A {@link BytesStream} used to write to ElasticSearch
   * @throws IOException
   *           If an error occurs during serialization
   */
  abstract BytesReference getContentBuilder(Map event) throws IOException;
}
